package com.yale.elasticsearch.controller.query;

import com.yale.elasticsearch.dto.MatchQueryDTO;
import com.yale.elasticsearch.service.query.MatchQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author :yale
 * @date : 2024/8/1
 */
@Api(tags = "查询-匹配查询")
@RestController
@RequestMapping("/query")
public class MatchQueryController {

    @Resource
    private MatchQueryService matchQueryService;

    @ApiOperation(value = "匹配查询全部数据", notes = "匹配查询全部数据")
    @PostMapping("/matchAll")
    public Object matchQueryAll(@Valid @RequestBody MatchQueryDTO matchQueryDTO) {
        return matchQueryService.matchAllQuery(matchQueryDTO);
    }

    @ApiOperation(value = "匹配查询", notes = "匹配查询数据")
    @PostMapping("/match")
    public Object matchQuery(@Valid @RequestBody MatchQueryDTO matchQueryDTO) {
        return matchQueryService.matchQuery(matchQueryDTO);
    }

    @ApiOperation(value = "词语匹配查询", notes = "词语匹配查询")
    @PostMapping("/matchPhrase")
    public Object matchPhraseQuery(@Valid @RequestBody MatchQueryDTO matchQueryDTO) {
        return matchQueryService.matchPhraseQuery(matchQueryDTO);
    }

    @ApiOperation(value = "多字段匹配查询", notes = "多字段匹配查询")
    @PostMapping("/matchMulti")
    public Object matchMultiQuery(@Valid @RequestBody MatchQueryDTO matchQueryDTO) {
        return matchQueryService.matchMultiQuery(matchQueryDTO);
    }

}
